//delegate.h use signal macro

#ifndef _1baa1c44_b650_4996_ba6b_3ca0bc8e3e4f__DELEGATE_H__
#define _1baa1c44_b650_4996_ba6b_3ca0bc8e3e4f__DELEGATE_H__

#include <vector>

#include "mutex.h"
#include "macro.h"
#include "exception.h"

namespace delegate
{
class Event
{
public:
	Event() :
			source_(0), data_(0), type_(0)
	{
	}
	Event(void* source, void* data = NULL, const int& type = 0)
	{
		source_ = source;
		data_ = data;
		type_ = type;
	}
	Event(const Event& rhs)
	{
		*this = rhs;
	}
	Event& operator=(const Event& rhs)
	{
		source_ = rhs.source_;
		data_ = rhs.data_;
		type_ = rhs.type_;
		return *this;
	}
	void setSource(void* source)
	{
		source_ = source;
	}
	void* source() const
	{
		return source_;
	}
	void setType(const int& type)
	{
		type_ = type;
	}
	int type() const
	{
		return type_;
	}
	void setData(void* data)
	{
		data_ = data;
	}
	void* data() const
	{
		return data_;
	}
protected:
	void* source_;
	void* data_;
	int type_;
};
}

namespace delegate
{
template<typename T, typename LockPolicy = threadmutex::NoMutex>
class Delegate;
}

#define Delegate_Num_Args	0
#include "delegate_implement.h"
#undef Delegate_Num_Args

#define Delegate_Num_Args	1
#include "delegate_implement.h"
#undef Delegate_Num_Args

#define Delegate_Num_Args	2
#include "delegate_implement.h"
#undef Delegate_Num_Args

#define Delegate_Num_Args	3
#include "delegate_implement.h"
#undef Delegate_Num_Args

#define Delegate_Num_Args	4
#include "delegate_implement.h"
#undef Delegate_Num_Args

#define Delegate_Num_Args	5
#include "delegate_implement.h"
#undef Delegate_Num_Args

#define Delegate_Num_Args	6
#include "delegate_implement.h"
#undef Delegate_Num_Args

#define Delegate_Num_Args	7
#include "delegate_implement.h"
#undef Delegate_Num_Args

#define Delegate_Num_Args	8
#include "delegate_implement.h"
#undef Delegate_Num_Args

#define EventHandle(T,E,N) Delegate<T (E*)> N

#endif //_1baa1c44_b650_4996_ba6b_3ca0bc8e3e4f__DELEGATE_H__
